package com.wlj.web.filter;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import java.io.IOException;
import java.util.Date;

/**
 * 如何要引用第三方过滤器，且它没有@component注解，如何把它加入到项目里来呢?
 * 请查看WebConfig
 */
//@Component
public class TimeFilter implements Filter {

    private Logger logger= LoggerFactory.getLogger(getClass());

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }

    //过滤器的不足:不知道处理这个请求的是哪个controller的哪个方法
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
            throws IOException, ServletException {
//        long start=new Date().getTime();
        filterChain.doFilter(servletRequest,servletResponse);
//        System.out.println("time filer耗时:"+(new Date().getTime()-start));
    }

    @Override
    public void destroy() {

    }
}
